package com.example.springboothazelcast.service;

import com.example.springboothazelcast.model.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    private static final Logger logger = LoggerFactory.getLogger(UserService.class);

    @Cacheable(value = "user", key = "#id")
    public User getById(Integer id) {
        logger.info("getById: {}", id);
        User user = new User();
        user.setId(1);
        user.setName("张三");
        return user;
    }
}
